perm filename MUSIC.TVR[UP,DOC]8 blob sn#237251 filedate 1976-09-19 generic text, type T, neo UTF8


STANFORD ARTIFICIAL INTELLIGENCE LABORATORY        September 19, 1976


**** DRAFT **** DRAFT **** DRAFT **** DRAFT **** DRAFT **** DRAFT ***









                            Music Manual



                                 by


                                Tovar







ABSTRACT:

This document describes the compiler/interpeter, MUSCMP, used  in the
Stanford Computer  Music System.   It includes  a description  of the
language and its use.  MUSCMP  is the successor to MUS10,  written by
David W. Poole  and is a  descendant of MUSIC  IV, written by  Max W.
Mathews.
                            Music Manual


                  T A B L E   O F   C O N T E N T S



                               SECTION                           PAGE



Section 1   Introduction

Section 2   Declarations
             2-1     Identifiers .  .  .  .  .  .  .  .  .  .  .  . 3
             2-2     Variable Declaration .  .  .  .  .  .  .  .  . 3
             2-3     Array Declaration .  .  .  .  .  .  .  .  .  . 4
             2-4     Function Declaration .  .  .  .  .  .  .  .  . 5
             2-5     Instrument Declaration  .  .  .  .  .  .  .  . 6

Section 3   Expressions
             3-1     Function Call: .  .  .  .  .  .  .  .  .  .  . 8
             3-2     Unit Generator Call  .  .  .  .  .  .  .  .  . 8
             3-3     Array Subscripting   .  .  .  .  .  .  .  .  . 8

Section 4   Statements
             4-1     Function Call: .  .  .  .  .  .  .  .  .  .   10
             4-2     Unit Generator Call  .  .  .  .  .  .  .  .   10
             4-3     Assignment Statement .  .  .  .  .  .  .  .   11
             4-4     WHILE Statement   .  .  .  .  .  .  .  .  .   11
             4-5     UNTIL Statement   .  .  .  .  .  .  .  .  .   11
             4-6     FOR Statement  .  .  .  .  .  .  .  .  .  .   12
             4-7     PRINT Statement   .  .  .  .  .  .  .  .  .   12
             4-8     Block .  .  .  .  .  .  .  .  .  .  .  .  .   13
             4-9     RETURN Statement  .  .  .  .  .  .  .  .  .   14
             4-10    DONE and EXIT Statements   .  .  .  .  .  .   14

Section 5   Extended Commands

Section 6   Unit Generators
             6-1     Controlled Calling Rates   .  .  .  .  .  .   17
             6-2     VFMULT   .  .  .  .  .  .  .  .  .  .  .  .   17
             6-3     LINEN .  .  .  .  .  .  .  .  .  .  .  .  .   18
             6-4     VALUE .  .  .  .  .  .  .  .  .  .  .  .  .   18
             6-5     The OSCIL family of Unit Generators .  .  .   19
             6-6     The ZOSCIL Family of Unit Generators   .  .   20
             6-7     The RAND Family of Unit Generators  .  .  .   22

Section 7   Built-in Functions
             7-1     SYNTH .  .  .  .  .  .  .  .  .  .  .  .  .   23
             7-2     SEG   .  .  .  .  .  .  .  .  .  .  .  .  .   23

                               Page i
                            Music Manual


             7-3     SEE   .  .  .  .  .  .  .  .  .  .  .  .  .   24
             7-4     SETCLOCK .  .  .  .  .  .  .  .  .  .  .  .   24
             7-5     PRINT .  .  .  .  .  .  .  .  .  .  .  .  .   24
             7-6     RDNUM .  .  .  .  .  .  .  .  .  .  .  .  .   25
             7-7     LENGTH   .  .  .  .  .  .  .  .  .  .  .  .   25
             7-8     RAND  .  .  .  .  .  .  .  .  .  .  .  .  .   25
             7-9     INT   .  .  .  .  .  .  .  .  .  .  .  .  .   26
             7-10    FORTRAN Functions .  .  .  .  .  .  .  .  .   26

Section 8   Computing sound
             8-1     PLAY Block  .  .  .  .  .  .  .  .  .  .  .   27
             8-2     Instrument Call   .  .  .  .  .  .  .  .  .   28
             8-3     FINISH statement  .  .  .  .  .  .  .  .  .   30

Section 9   Outputting the sound
             9-1     Short segments directly from MUSCMP .  .  .   31
             9-2     Longer segments using MUSCMP to write
                              a sound file   .  .  .  .  .  .  .   31
             9-3     Production runs   .  .  .  .  .  .  .  .  .   31

Appendix A  Syntax   .  .  .  .  .  .  .  .  .  .  .  .  .  .  .   33

Appendix B  Reserved Words .  .  .  .  .  .  .  .  .  .  .  .  .   36

Appendix C  Predefined Symbols   .  .  .  .  .  .  .  .  .  .  .   37

Appendix D  Error Messages.   .  .  .  .  .  .  .  .  .  .  .  .   39

Appendix E  Changes since MUS10  .  .  .  .  .  .  .  .  .  .  .   47




















                               Page ii
Music Manual


                              Section 1
                              _______ _

                            Introduction
                            ____________




The music compiler features a subset of ALGOL with special operations
directed toward music synthesis.  There are three modes  the compiler
can be in.  It can be in  COMPILE mode, where  instrument definitions
are accepted and compiled. It can be in PLAY mode, where it accepts a
note list and invokes these instruments to generate a sound waveform.
If  you  are  not  in  either  COMPILE  or  PLAY  mode,  you  are  in
interpretive mode, where  any ALGOL statements given  get interpreted
on the spot.


































                               Page 2
Music Manual


                              Section 2
                              _______ _

                            Declarations
                            ____________






2-1. Identifiers
     ___________


<identifier>            ::= <letter>{<alphanumeric>}
<alphanumeric>          ::= <letter>|<number>
<letter>                ::= A|B|C|...Z|_|$|#
<digit>                 ::= 0|1|2|...9


An identifier always  begins with a letter  and may be  followed with
any number of  letters or digits.   There are three  characters which
are treated as letters, $, # and _.  Lower case letters are converted
                        _  _     _
to upper case.  Certain  identifiers have special meanings  which may
not be used as names for variables, functions, arrays or instruments.
There  are  two kinds,  P  and U  variables,  which are  of  the form
P<number> and U<number> (see below) and reserved words like  ARRAY or
_             _                                              _____
BEGIN.  A list of reserved words is contained in Section 2.
_____



2-2. Variable Declaration
     ________ ___________


<variable declaration>  ::= VARIABLE <identifier>{,<identifier>};


All  variables must  be declared  before they  are used.   A variable
declaration consists of the reserved word VARIABLE followed by a list
of identifiers to  be declared as  variables.  All variables  must be
declared before they are used.

If variables are to be  used during R-Time (see Section ),  they must
be declared as R-Time variable by preceding each variable name with a
slash in their declaration.
There are certain  variables, P1,P2,P3,..Pn and  U1,U2,U3,...Un which
have special meanings. Pn is the nth element of the P_Array, which is
the  list  of  parameters  to  an  instrument.  Within  an instrument
definition, Un is  the output of the  nth unit generator  within that
instrument definition.

                               Page 3
Music Manual                                             Declarations


All variables are stored  in floating point representation,  with two
exceptions.  One exception is in function definitions, where the data
types STRING  and INTEGER  are also  allowed, for  compatability with
external FORTRAN callable subroutines.  The second exceptions  are P-
variables, which do  not have a  specific type associated  with them.
This  means they  can  be used  as  variables, arrays,  and  so forth
without regard to type, hence  one must be careful using them  as one
can easily  make the mistake  of using a  number instead of  an array
with most unpredicatable results  (usually causes an ILL MEM  REF, or
                                                     ___ ___  ___
illegal memory reference).

Example:

VARIABLE A,B,/C,D,/RT;  COMMENT Declares A,B,D to be I-Time variables
                                Declares C,RT to be R-Time variables;



2-3. Array Declaration
     _____ ___________


<array declaration>  ::= ARRAY <array decl. list>
<array decl. list>   ::= <variable>[(<constant>)]
                            {,<array decl. list>}|
                         <variable>(<constant>)

All arrays must be declared before they are used and  contain numbers
in floating point  representation.  An array declaration  consists of
the  reserved  word  ARRAY  followed  by  a  list  consisting  of the
identifier followed  by the array  size in parenthesis,  separated by
commas.  If there are several  arrays of the same size, the  size may
be  omitted on  all but  the  last array  of that  size.   Arrays are
currently restricted to  single subscripts and elements  are numbered
from 0 to n-1. Arrays within blocks are not dynamically allocated(1);
they are allocated at compile time, hence they must be a  fixed size.
Take note that arrays are not initialized and may contain practically
anything.

Example:

ARRAY F1,F2,F3(512),BAZ(2000);  COMMENT Declares F1, F2, F3 to be
                                arrays of length 512, BAZ to be an
                                array of length 2000;
Note: Array subscripts  always start with 0  and thus have  a maximum
subscript of one less than  the size of the array.  Thus,  F3[511] is
                                                           _______

_______________________
(1) Dynamic allocation will probably be implemented in the future.

                               Page 4
Music Manual                                             Declarations


the last element of the array F3 defined in the example.  See  Page 8
                              __
for details on referencing elements of an array.



2-4. Function Declaration
     ________ ___________

<function declaration>  ::= FUNCTION <identifier>(<formal list>)
                                <function tail>|
                            EXTERNAL FUNCTION <identifier>
                                (<formal list>)
<formal list>           ::= <formal declaration>{,<formal list>}
<formal declaration>    ::= ARRAY <identifier> |
                            INTEGER <identifier>|
                            STRING <identifier> |
                            <identifier>
<function tail>         ::= ; <block> | = <expression>


A  function declaration  defines a  function in  MUSCMP.   A function
takes from 0 to n  arguments, which may be variables,  arrays, string
constants or expressions and returns a value, which is a real number.
Functions are executed at  either I-time or R-time, depending  on the
arguments at the time they are called (see Page ).

The function declaration includes a list of formal  parameters, which
represent  their respective  actual  arguments when  the  function is
called.  The formal parameters are local variables in terms of scope,
that  is they  are  known only  within  the function  which  they are
declared.  Their use  outside that  function will  have one  of three
results.  If the  variable is not  defined outside that  function, an
error message will be issued.  If it is defined to be of  a different
type, an  error message will  also be issued,  except in a  PLAY list
where type checking is not  as stringent (for details, see  Page 29).
If it  is defined outside  the function  to be of  the same  type, no
error message  will occur, the  result is likely  not to be  what was
intended.
Functions are always called  by reference(1), which means that  if an
assignment  is done  to one  of the  formal parameters,  the argument
itself will be modified.  Such assignments are  strongly discouraged,
since if the function is  called with a constant as an  argument, the
constant's value will be  changed, which usually has  disastorous and
mysterious results!

There are three  forms of function  declaration.  In the  first form,

_______________________
(1) This is the standard  FORTRAN IV calling sequence on the PDP-10.

                               Page 5
Music Manual                                             Declarations


the value of the function is the value of the expression to the right
of the '='.  For example, the following function calculates  the cube
of a number.

FUNCTION CUBE(X) = X * X * X;

PRINT CUBE(2);
8.


The second form is used for more complex functions.  Its value is the
expression part  of the  last RETURN  statement executed  within that
                              ______
function,  as  there may  be  more  than one  RETURN  statement  in a
                                              ______
function.  For example,   the following function returns  the maximum
amplitude of an waveform contained in an array.

FUNCTION AMPLITUDE(ARRAY M);
  BEGIN VARIABLE I,MAX;
    MAX←0;                  COMMENT Initialize maximum amplitude;
    FOR I ← 0 STEP 1 UNTIL LENGTH(M)-1
      DO IF ABS(M[I])>MAX THEN MAX←ABS(M[I]);
                            COMMENT Compare each element with
                                current maximum;
    RETURN MAX;             COMMENT The value of the function is
                                the maximum amplitude found;
    END;

The third form  is used for functions  written in FORTRAN  or machine
code.  It defines the argument list which the function expects to see
and fetchs the address from DDT's symbol table.  This means  that you
must to  use the same  name for  the function as  was written  in the
program or  MUSCMP will not  find its address!   The following  is an
example of this form of declaration.

EXTERNAL FUNCTION SQRT(X);


WARNING:  The syntax for formal declaration may be changed someday to
conform to ALGOL.



2-5. Instrument Declaration
     __________ ___________

<instrument declaration>::= INSTRUMENT <identifier>;
                            <declaration list>;<statement list>



                               Page 6
Music Manual


                              Section 3
                              _______ _

                             Expressions
                             ___________




<expression>    ::= <simple expr><relop><simple expr>|<simple expr>
<simple expr>   ::= <term>|<term><addop><simple expr>
<term>          ::= <factor>|<factor><mulop><term>
<factor>        ::= <primary>
<primary>       ::= -<primary>|(<expression>)|<function call>|
                    <unit generator call>|<variable>←<expression>|
                    <variable>|<array ref>|<constant>
<array ref>     ::= <array name>[<expression>]
<relop>         ::= <|=|>|α≤|≠|≥
<addop>         ::= +|-
<mulop>         ::= *|/


Expressions are like algebraic formulae with certain changes required
so that they may  be typed on a  keyboard.  For example, '*`  is used
instead of 'x` and '/`  has been used to indicate division.   The use
of parenthesis is similar, but the following:

                3+4␈_5
                ___ _
                 7␈2

should be  written as (3+4*5)/(7*2),  not 3+4*5/7*2.  When  in doubt,
                      _____________       _________
put in the extra parenthesis.  In mathematical notation, there  is an
implied  multiplication   frequently  used   which  must   be  stated
explicitly in MUSCMP,  therefore 2x+3 should be written as  2*X+3. It
                                                            _____
is  also  necessary  to  expiicately  parenthesis  the  arguments  to
functions which would not  be required in mathematical  notation, for
example, sin x should be written as SIN(X).
                                    ______

Relational operators, (as in x >  4) are defined to evaluate to  0 if
false and 1 if true.  One should use care with the operators  '=' and
'≠' as  floating point  arithmetic is  not exact(1)  discussion.  For
example:
PRINT 3/5+2/5 = 1;
0



_______________________
(1) See Knuth, The  Art of Computer Programming, Section  4.2.2 (Vol.
               ___  ___ __ ________ ___________
II) if you really want to know about this.

                               Page 7
Music Manual                                              Expressions


3-1. Function Call:
     ________ _____


<function call> ::= <function>(<parameter list>)
<parameter list>::= <parameter>,<parameter list>|<parameter>
<parameter>     ::= <expression>|<array>|<string constant>


A function call consists of  the function name followed by a  list of
parameters  separated by  commas  and enclosed  by  parenthesis.  The
effect is  to call  the function  (or subroutine)  with that  list of
parameters.  If the function is  not defined to return a  value, such
as a FORTRAN subroutine, the  value of the function is  undefined and
may be almost anything. For additional information on  functions, see
Page 5.  For descriptions of  the built-in functions  available,  see
Page 23.

Example:

PRINT SQRT(2);

1.414213



3-2. Unit Generator Call
     ____ _________ ____


A unit  generator is a  special kind of  function, as it  may contain
both at I-time and  R-time code and requires  special initialization,
Hence a unit generator call is only legal within an instrument.  Note
that a unit generator call within an expression can not be refered to
by Un.   Only unit generators  used as statements  are counted  for U
   _                                                                _
symbols.  See Section 6.



3-3. Array Subscripting
     _____ ____________


<array ref>     ::= <array name>[<expression>]


One can reference  particular elements of  an array by  following the
array name with the  index in square brackets(1). Thus,  F1[5] refers
                                                         _____

_______________________
(1) Parentheses are also acceptable here.

                               Page 8
Music Manual                                              Expressions


to element number 5 in the array F1.  Since arrays are always contain
                                 __
floating point  numbers, the construction  F1[5] represents  a single
                                           _____
floating point number and can be used like a variable.

It is important  to note that array  start with element number  0 and
thus if an array  F1 is of size n,  the last element of the  array is
                  __
F1[n-1].  For  example, the  following loads an  array, F1,  with one
___                                                     __
cycle of a sine wave:

ARRAY F1(512);
BEGIN VARIABLE I;
  FOR I←0 STEP 1 UNTIL 512-1
    DO F1[I]←SIN(I/512);
  END;


The index,  also known as  the subscript, is  check for  being within
range,  with   one  important   exception.   In   instruments,  array
references done at R-Time  are not check for efficiency  reasons.  If
an array reference is out of bounds, i.e. less than 0 or greater than
or equal to the array size, a diagnostic is printed.  For example:

I←512;
PRINT F1[I];

Subscript of out bounds for array F1, subscript = 512
??


It should  be noted  that since  number is  stored in  floating point
representation, it must be converted to an integer before referencing
the  array  element.   This conversion  is  accomplished  by  the INT
                                                                  ___
function  (see  Page  26)  and  is  NOT  the  same  as  rounding.  If
multiplication or  division is  done on  floating point  numbers, one
often gets something like 4.99999 instead of 5.0 as a result and when
this is used as a index, it will give the element number 4 instead of
5 as one might naively expect.












                               Page 9
Music Manual


                              Section 4
                              _______ _

                             Statements
                             __________



<statement>     ::= <function call>|<unit generator call>|
                    <WHILE statement>|<UNTIL statement>|
                    <FOR statement>|<conditional statement>|
                    <PRINT statement>|<assignment statement>|
                    <RETURN statement>|EXIT|DONE|
                    <block>



4-1. Function Call:
     ________ _____

<function call> ::= <function>(<parameter list>)
<parameter list>::= <parameter>,<parameter list>|<parameter>
<parameter>     ::= <expression>|<array>|<string constant>


A function call consists of  the function name followed by a  list of
parameters  separated by  commas  and enclosed  by  parenthesis.  The
effect is  to call  the function  (or subroutine)  with that  list of
parameters.  If the function returns a value, that value is lost.

Example:

SYNTH(F1);              COMMENT Call the function SYNTH with F1
                                as an argument;



4-2. Unit Generator Call
     ____ _________ ____

<unit generator call> ::= <unit generator>(<parameter list>)|
                <unit generator>[<expression>](<parameter list>)


A unit  generator is a  special kind of  function, as it  may contain
both at I-time and  R-time code and requires  special initialization,
Hence a unit generator call  is only legal within an  instrument. The
value of nth unit generator in an instrument can be refered to by Un.
                                                                  _
Only unit generators used as statements are counted for U symbols, if
                                                        _
a unit generator is used  with an expression it is not  counted.  See
Section 6.


                               Page 10
Music Manual                                               Statements


4-3. Assignment Statement
     __________ _________


<assignment statement> ::= <variable>←<expression>

This statement assigns the value of the expression to the variable to
the left of  the `←'  Caution: Assignment  to formal parameters  of a
function can have unexpected results;  see Page 5.

Example:

I←123;          COMMENT Set the value of the variable 'I` to 123;



4-4. WHILE Statement
     _____ _________

<WHILE statement> ::= WHILE <conditional> DO <statement>

A WHILE statement consists of the reserved word WHILE, an expression,
                                                _____
called  the  condition  followed  by  the  reserved  word  DO  and  a
                                                           __
statement.  So long  as the  condition is  true, i.e.  not  zero, the
statement will  be repeated  indefinitely.  Generally,  the statement
affects  part   of  the  condition   and  the   statement  eventually
terminates.

Example:

I←1; WHILE I<1000 DO PRINT(I←2*I);

2. 4. 8. 16. 32. 64. 128. 256. 512. 1024.



4-5. UNTIL Statement
     _____ _________


<UNTIL Statement> ::= DO <statement> UNTIL <conditional>

An  UNTIL  statement  is  like an  WHILE  statement  except  that the
statement is executed before  the condition and loop  terminates when
the  condition is  true.   It consists  of  the reserved  word  DO, a
                                                                __
statement followed by the reserved word UNTIL and an  expression, the
                                        _____
condition.





                               Page 11
Music Manual                                               Statements



Example:

I←10; DO PRINT(I←I-1) UNTIL I≤0;

9. 8. 7. 6. 5. 4. 3. 2. 1. 0



4-6. FOR Statement
     ___ _________


<FOR statement> ::= FOR <variable>←<expression> STEP <expression> 
                      UNTIL <expression> DO <statement>

This performs the statement for each value of the variable, beginning
with the expression immediately following the `←' in steps defined by
the second expression until it is greater than the  third expression.
The value  of the variable  will always be  the last value  which was
less than the third  expression.  If the first expression  is greater
than the third expression,  the statement will be  skipped altogether
and the variable unchanged.

Example:

FOR I←0 STEP 2 UNTIL 20 PRINT(I);

0 2. 4. 6. 8. 10. 12. 14. 16. 18. 20.



4-7. PRINT Statement
     _____ _________


<PRINT statement> ::= PRINT <print list>
<print list>      ::= <expression>,<print list>|<expression>|
                      <string constant>,<print list>|
                      <string constant>
This  types each  number or  string in  the print  list.  Numbers are
printed  in free  field format  with a  trailing space.   Strings are
printed  without a  leading  or trailing  space and  may  include any
character.  To enter a double quote, precede it with `≡' and to enter
                                                      _
`≡', put in two consecutive `≡'s.
 _                           _






                               Page 12
Music Manual                                               Statements



Example:

PRINT "SQRT(2) = ",SQRT(2);

SQRT(2) = 1.41423



4-8. Block
     _____


<block>            ::= BEGIN <declaration list>;<statement list>
<declaration list> ::= <declaration>;<declaration list>|<declaration>
<statement list>   ::= <statement>;<statement list>|END

A Block  is a  list of  statements, brackets  by the  reserved words,
BEGIN and  END and  separated by  the semicolons.   Anything declared
within a block is a local variable and therefore is not known outside
that block,  but anything which  is declared outside  a block  may be
referenced within that block provided that it has not been redefined.
Thus  variables  names  within  blocks  maybe  chosen  without  being
concerned  with  name  conflicts.   (See  also  discussion  of  local
variables in functions on Page 5.)

Example:

VARIABLE X; X←123; PRINT X;

123.

BEGIN VARIABLE X,Y;  X←456; Y←789;  PRINT X,Y;  END;

456. 789.

PRINT X;

123.

PRINT Y;

ERROR:  UNDEFINED IDENTIFIER    Line = 7 /1
PRINT Y;
       ↑
??




                               Page 13
Music Manual                                               Statements


4-9. RETURN Statement
     ______ _________

<RETURN statement> ::= RETURN <expression>

A RETURN statement is only valid within a function definition.  It is
  ______
used to terminate execution of a function and to return as  the value
of that  function, the expression  immediately following  the RETURN.
                                                              ______
There may be more than one RETURN statement in a given function.  See
                           ______
Page 6) for more information and an example.



4-10. DONE and EXIT Statements
      ____ ___ ____ __________

A DONE statement is only valid within a FOR, WHILE, or UNTIL loop and
  ____                                  ___  _____     _____
serves provide an alternative means of terminating execution  of that
loop.  There may be more than one DONE statement in a given loop.  If
                                  ____
two loops are nested, the DONE only finishs from the innermost loop.
                          ____

An EXIT statement  provides for early  termination of a  block.  Like
   ____
the DONE statement, it only exits the innermost block.
    ____

DONE statements can appear  in blocks and EXIT statements  can appear
____                                      ____
in loops.  In such cases, both the block and the loop are exited.

The following example illustrates several uses of EXIT and DONE

COMMENT Print the first 100 prime numbers;

VARIABLE N,I;

PRINT 2;                        COMMENT Only even prime;
FOR N←3 STEP 2 UNTIL 100 DO     COMMENT Skip the rest of the evens;
  BEGIN
    FOR I←3 STEP 2 UNTIL N DO   COMMENT Try each factor;
      IF N = I*INT(N/I)         COMMENT If it divides evenly, stop;
          THEN EXIT             COMMENT (Exits block and continues
                                        outer FOR);
        ELSE IF N/I<I           COMMENT Don't bother past its square;
          THEN DONE;            COMMENT root. (Exits inner FOR);
    PRINT N;                    COMMENT We found one;
    END;                        COMMENT (of FOR loop);







                               Page 14
Music Manual


                              Section 5
                              _______ _

                          Extended Commands
                          ________ ________




These commands may be entered at the top level by preceding them with
an <alt mode> (which is echoed as $).
                                  _

Exit:                        <alt mode>EXIT
____

Return to Monitor.

Play:                        <alt mode>P <integer>
____
Plays the music buffered in  core the specified number of  times.  If
no argument is given, one is assumed.

Save:                        <alt mode>SAVE
____

Saves the music buffered in  core on a disk file.  At  Stanford, this
is in 12 bit format.

Print:                       <altmode>PRINT <expression>;
_____

Prints the value  of the expression. It  used to only be  an extended
command.   It is  now  generalized as  an regular  statement  and the
extended command is considered obsolete. See PRINT Statement  on Page
12.

Reduce Core size:            <alt mode>EXCISE
______ ____ ____

Reduces to the minimum core required.

Space:                       <alt mode>SPACE
_____

Prints the total  space available followed  by the core  buffer space
and the number of seconds of sound which may be produced.

DDT:                         <alt mode>DDT
___

Starts up RAID or DDT. [Not usually loaded in system version  but may
be in other core images.]






                               Page 15
Music Manual                                        Extended Commands



Printing the Symbol Table:   <alt mode><declarator> LIST
________ ___ ______ _____
This list  the contents of  the symbol table.  Please note  that this
does not include symbols in inner blocks.  The following types may be
listed:

        VARIABLE
        FUNCTION
        ARRAY
        INSTRUMENT
        UNIT_GENERATOR






































                               Page 16
Music Manual


                              Section 6
                              _______ _

                           Unit Generators
                           ____ __________




Consider producing the  sound of a simple  sine wave.  If one  had to
call the sine subroutine for  each sample, it would take a  long time
to  compute a  second  of sound  even  at the  lowest  sampling rate.
Therefore, instead of calculating  the function for every  sample, an
array is  filled with  the values  of the  function.  Then,  for each
sample, the value is read out of the appropriate entry in  the array,
instead of calculating it.   Of course, for many kinds  of functions,
the value  will not be  as particalarly accurate,  but it  is usually
adequate  for  use in  music.   There are  unit  generators  which do
interpolation,  instead  of a  simple  array lookup,  and  these will
produce accurate enough values for most critical cases.



6-1. Controlled Calling Rates
     __________ _______ _____


In  many  cases,  a  function  does  not  change  rapidly  with time.
Therefore to save computer time, it would be desirable not to have to
call the unit  generator for every sample.   This, which is  called a
controlled  calling  rate,  is  expressed  by  placing   a  bracketed
expression immediately  following the unit  generator name in  a unit
generator call.

Example:

        OSCIL[10](P4,10*MAG/P2,F1);

Calls the unit generator OSCIL every tenth sample, and uses the same
value for the other nine samples.




6-2. VFMULT
     ______


Argument list:

        1 - Amplitude
        2 - Subscript

                               Page 17
Music Manual                                          Unit Generators


        3 - Array

VFMULT multiplies the first  argument times the element of  the array
described by the  second argument. If  the second argument  is getter
than the array length, it is reduced by that array length until it is
within the size of the array.



6-3. LINEN
     _____


Argument list:

        1 - Amplitude
        2 - Rise time
        3 - Decay time
        4 - Total time
        5 - Array
        6 - Initial point in array

This function uses a 384 word array in three sections, to generate an
envelope  function with  separate  rise time,  intermediate  time and
decay  time.  The  rise time  and decay  time are  a function  of the
second argument, third argument and the total time.  Their  values in
seconds may be calculated according to the following formula.

To obtain a rise time of .1 seconds and a decay time of .4 seconds,

LINEN(P4,.1,.4,P2,F1,TMP←0);


CAUTION: The  initial point in  array must be  a variable  and should
usually be zero. If it is  a constant, you will clobber the  value of
that  constant  with most  unpredicable  results.   Furthermore, this
variable should be  different for each  unit generator call,  or else
the unit generators will interfere with each other.



6-4. VALUE
     _____


Argument list:

        1 - Expression



                               Page 18
Music Manual                                          Unit Generators


VALUE is a special  unit generator which returns its  first parameter
as  its value.   Its  sole reason  for  existent is  to  allow R-time
expressions  to be  evaluated with  a controlled  calling  rate.  For
example,
VALUE[100](RV←A*SIN(X));


stores the value of A*SIN(X) into the variable RV every 100 samples.



6-5. The OSCIL family of Unit Generators
     ___ _____ ______ __ ____ __________


OSCIL is short for oscillator. An OSCIL outputs successive  values of
the function (or waveform) stored  in an array.  When it  reached the
end of that array, it `wraps around' and starts back at the beginning
of  the array.   The  rate at  which it  moves  down the  array  is a
parameter  called  the  increment,  measured  in  array  elements per
sample,  which  is equal  to  the frequency  times  the  array length
divided  by the  sample rate.  For convenience,  there is  a variable
called MAG which is set to 512/SRATE, 512 being the length  of arrays
       ___                 _________  ___
used here and SRATE being the sample rate.  Since most functions used
              _____
with OSCIL range  between -1 and 1,  there is a parameter  called the
amplitude, by  which the value  of the function  is multiplied  by to
produce the value of unit generator.

The usual order of arguments is:

        1 - Amplitude
        2 - Increment
        3 - Array

The following are the many kinds of OSCIL's:

OSCIL:
_____

OSCIL always starts at the beginning of the array when the instrument
is called and will produce  an error message if a  negative increment
is supplied.

NOSCIL:
______

NOSCIL  always  starts  at  the  beginning  of  the  array  when  the
instrument is called and will accept a negative argument.

COSCIL:
______


                               Page 19
Music Manual                                          Unit Generators


COSCIL starts wherever it left off the last time that  instrument was
called.  (If there are more than one COSCIL's in an  instrument, they
do not effect each other.)  COSCIL will accept a negative argument.

EXPEN:
_____

EXPEN always  starts at  the beginning  of the  array and  instead of
'wrapping around` when it reachs the end, it always returns  the same
value upon subsequent calls.

NOSCA:
_____
Argument list:

        1 - Initial index in array
        2 - Amplitude
        3 - Increment
        4 - Array

INTRP:
_____
Argument list:

        1 - Input A
        2 - Input B
        3 - Increment
        4 - Array

INTRP is an unusual variant of OSCIL which almost deserves to be in a
class of its own.  Like  OSCIL, it scans down the array,  but instead
of multiplying by the amplitude, it interpolates between inputs A and
                                                                _
B.  To be more exact, the output is given by A*X+B*(1-X), where  X is
_                                            ___________         _
the array element(1).  The contents  of the array are expected  to be
between 0 and 1 for normal usage.



6-6. The ZOSCIL Family of Unit Generators
     ___ ______ ______ __ ____ __________


The  ZOSCIL  family  interpolates  between  the  two   closest  array
elements, rather that doing a straight lookup.  If it reaches the end
of an  array, it will  interpolate between the  last element  and the
first element, which may produce unexpected (but  consistent) results
for discontinuous functions.  ZOSCIL unit generators are  useful were
higher accuracy or or  smoothness is necessary, as for  Chowning's FM
sounds.

_______________________
(1) Actually the calculation is done as A+X*(B-A)
                                        _________

                               Page 20
Music Manual                                          Unit Generators



The typical paramenter list is:

        1 - Amplitude
        2 - Increment
        3 - Array

The following are the various kinds of ZOSCIL.

ZOSCIL:
______

ZOSCIL always starts at the beginning of the array and will  accept a
negative increment.

CZOSCIL:
_______

CZOSCIL interpolates between  the two closest array  elements, rather
that doing  a straight  lookup.  Like COSCIL,  it starts  wherever it
left off the last time the instrument was called. CZOSCIL will accept
negative increment.

ZEXPEN:
______

ZEXPEN is  like a  EXPEN except ZEXPEN  interpolates between  the two
closest array  elements, rather  that doing  a straight  lookup. Like
EXPEN, instead of 'wrapping around` when it reachs the end, it always
returns the same value upon subsequent calls.

ZOSCA:
_____
Argument list:

        1 - Initial point in array
        2 - Amplitude
        3 - Increment
        4 - Array

ZOSCA is a special form of  ZOSCIL which sets where it starts  in the
array to the value of the first argument.

ZINTRP:
______
Argument list:

        1 - Input A
        2 - Input B
        3 - Increment
        4 - Array



                               Page 21
Music Manual                                          Unit Generators


ZINTRP is  like a  INTRP except ZINTRP  interpolates between  the two
closest array elements to get a number to use to  interpolate between
the two inputs!  See description of INTRP on Page 20.



6-7. The RAND Family of Unit Generators
     ___ ____ ______ __ ____ __________


There are  two random  number generators that  are available  as unit
generators.   These are  RANDH and  RANDI. Both  of these  generate a
pseudo-random number  (via the linear  congruential method)  every so
often. The first argument  to these unit generators is  the amplitude
(it will go to plus  and minus that number), and the  second argument
is the  frequency (times MAG,  of course).  RANDH  will get  a random
number and hold it for one period (the time of which is determined by
the second  argument), whereas RANDI  will interpolate  linearly from
this point to the next.

Argument list:

        1 - Amplitude
        2 - Increment

For  example,  the following  will  generate five  random  number per
second between 440 and 660:

        FREQ←550+RANDH(220,5*MAG);





















                               Page 22
Music Manual


                              Section 7
                              _______ _

                         Built-in Functions
                         ________ _________






7-1. SYNTH
     _____


This is a FORTRAN subroutine, usually loaded with the Compiler, which
allows arrays to be loaded with the sum and/or product of sine waves.
To use  SYNTH, you must  dimension an array  to the  appropriate size
(presently 512) and call it with SYNTH(<array name>). You should then
                                 ______            _
input four numbers:

    1) the harmonic (denoted by H),
    2) the amplitude (denoted by A),
    3) the phase angle in degrees (denoted by P), and
    4) a constant with is added to the amplitude (denoted by K).

If K is  greater than 100  then it will  multiply instead of  add the
sine wave described.  It is terminated by the single entry of 999 for
H.  If you are at a III display,  after the four parameters,  the new
state of the array will be displayed.



7-2. SEG
     ___


Like SYNTH, this  is a subroutine  usually loaded with  the Compiler.
It allows  arrays to  be defined as  line segments.   To use  is, you
first must dimension an array to the appropriate size (presently 512)
and  call the  function  with SEG(<array  name>).   If you  are  at a
                              ____             _
display, it will display the  array as you load it. It  expects input
of two  numbers, the amplitude  and the position  in the array,  on a
scale from  0 to  100.  It  is terminated by  the entry  of 100  as a
position.


There is a version  of SYNTH and SEG which  will save the array  on a
file  in a  form which  may be  read by  the MUSCMP.   This is  in an
external program called FUNC.  If  you really want to know  about it,
see Leland Smith for details.


                               Page 23
Music Manual                                       Built-in Functions


7-3. SEE
     ___


Argument list:

1 - Array to be displayed

This routine displays the content of an array. It is called  with the
array to be displayed as  an argument in the form  SEE(<array name>).
                                                   __________ ______
Type  0<return> when  you are  done looking  at the  display  and the
      _
display will be cleared.



7-4. SETCLOCK
     ________


No Arguments

SETCLOCK may  be used to  setup NCHNS, SRATE  (the clock  or sampling
                                _____  _____
rate), and MAG to their appropriate values. When called, it  asks for
           ___
the number of channels and clock rate. It then sets MAG to 512/SRATE.
                                                    ___    _________
Available clock rates are 12800 and 25600.  Clock rates less than 100
are multiplied by 1000 (i.e. 12.8 becomes 12800);



7-5. PRINT
     _____

Argument list:

        1 - Number to be printed

Prints an integer  or floating point  number.  It is  mostly obsolete
and is here for  the use in compatablity  (see Page 12).  For  use in
FORTRAN  programs,  there  is   a  function  called  PNUM   which  is
                                                     ____
approximately equivalent to  PRINT. FORTRAN I/O is  incompatable with
MUSCMP and  attempts to  use it  will result  in various  errors like
ILLEGAL UUO AT XXX The difference in names is because the  name PRINT
would conflict with FORTRAN.









                               Page 24
Music Manual                                       Built-in Functions





7-6. RDNUM
     _____

Argument list:

        1 - Variable to recieve number

Inputs a number  from the current  input device.  Returns  a floating
point number.  Callable from FORTRAN, as FORTRAN I/O  is incompatable
with MUSCMP.



7-7. LENGTH
     ______

Argument list:

        1 - Array or string

Returns the length of a string or array.



7-8. RAND
     ____

Argument list:
        None

Generates pseudo-random numbers between -1 and 1(1).














_______________________
(1) The first time RAND is called, the number returned is  a function
of the time and date.

                               Page 25
Music Manual                                       Built-in Functions





7-9. INT
     ___

Argument list:

        1 - Number

Returns the integer part, or to be more precise the  entier function.
For example:

INT(123.456)=123
INT(-123.45)=-124

Note: At the moment, the version for a KI10 or KL10 uses the FORTRAN-
style INT, where INT(-123.456)=-123.  This should be fixed soon.



7-10. FORTRAN Functions
      _______ _________


The following functions are loaded from the FORTRAN Library:

        SQRT(X)            Square root
        _______

        SIN(X)             Sine in radians
        ______
        SIND(X)            Sine in degrees
        _______

        COS(X)             Cosine in radians
        ______
        COSD(X)            Cosine in degrees
        _______

        ALOG(X)            Natural logarithm
        _______
        ALOG10(X)          Logarithm base 10
        _________

        ABS(X)             Absolute value
        ______

                            x
        EXP(X)             e
        ______









                               Page 26
Music Manual


                              Section 8
                              _______ _

                           Computing sound
                           _________ _____






8-1. PLAY Block
     ____ _____

<play block>      ::= PLAY; <play list> |
                      PLAY <filespec>; <play list>
<play list>       ::= <instrument call>;<play list>|
                      <statement>;<play list>|
                      FINISH
<instrument call> ::= <instrument><parameter list>
<filespec>        ::= <filename><switches>|
                      <filename>
<switches>        ::= <switch><swiches>|<switch>
<switch>          ::= /BYTESIZE=<number>|
                      /SOUND


The play list specifies  when instruments are started, how  long they
are to  run, and what  paramenters they are  called with.   It starts
with PLAY  followed by  an optional output  file specification  as to
     ____
where  the output  is to  be directed.  If no  file  specification is
given, PLAY must be followed with a semicolon. MUSCMP knows about the
       ____
following devices at Stanford:

        DAC:  Digital-to-Analog converter
        ____
        DSK:  Disk file
        ____
        MTAn:     Magnetic tape (`magtape')
        _____
        UDP:  [Old format] user disk pack.(1)
        ____

If no  device is  specified, DSK:  is assumed  with the  exception of
                             ____
DAC:,  the default  is 18  bits  with the  last sample  in  each file
____
containing the maximum amplitude seen so far.  Magtape is  written in
a special format as  magtape does not ordinarily contain  a directory
or other indicates on the contents of that tape.(2) Unless  the sound

_______________________
(1)  One could  write on  new  format UDP  by also  putting  the file
containing the play  list on the UDP  and giving the  moniter command
ASSIGN UDP1 DSK just before inputing the play list.
______ ____ ___

(2) If you need to know the exact format, see Section 

                               Page 27
Music Manual                                          Computing sound


is fairly short,  it will be  broken up into  a number of  files with
progressively  increasing extensions.   For example,  if  you specify
FOO.0 as the output file, MUSCMP will write FOO.0, FOO.1, FOO.2, etc.
_____                                       _____  _____  _____
Whenever it finishes a file,  it also writes itself out on  your disk
area as XXX.SAV, where  XXX is the name  of your input file.   If the
        _______
system crashes or  you decide you want  to go home, you  can continue
the computation later  by saying RUN  XXX.SAV.  This even  applies to
                                 ___  _______
magtape,  although you  will have  to mount  it on  the  same logical
drive(1) and it may take awhile to find where it left off.
If a digital-to-analog converter is specified, you maybe  specify the
number of seconds to be  buffered in core memory by using  a floating
point number in place of the  file name which must have at  least one
digit preceding and following the period.  For example,  PLAY DAC:1.0
                                                         ____ _______
specifies  a  buffer for  one  second  of sound.   If  more  sound is
generated that specified  by the core buffer,  it will be put  out in
several discontinuous segments.



8-2. Instrument Call
     __________ ____


The rest of a PLAY block consists of instrument calls  or statements.
A statement  is as described  in Section 10.   An instrument  call is
much like a function call.  It consists of the name of an instrument,
followed by a list  of parameter (or arguments).  When  an instrument
is called, the paramenters  are placed in corresponding  Pn variables
                                                         _
and  the  initialization  code  of  the  instrument  is  called.  The
initialization  code  saves   the  Pn  variables  and   preforms  any
                                   _
computations  which only  involve  I-time variables  (see  Section ).
The  rest  of the  instrument  code  is not  run  until  a subsequent
instrument call is read and  initialized which does not start  at the
same time, or  a FINISH statement is  seen.  Then each  instrument is
run, one  sample at a  time, until the  next instrument is  to begin.
Then more instrument calls are read until the next one is found which
begins at  a lster  time, and the  cycle is  repeated until  a FINISH
statement is seen and all instruments are finished.  As an instrument
finishes, it is  removed from the list  of instruments to be  run for
each sample.

Example:


_______________________
(1) You  can get  around this restriction  using the  ASSIGN command.
                                                      ______
Suppose you need MTA0 but only MTA1 is available.  Say to the system,
ASSIGN  MTA1 MTA0  and any  program refering  to MTA0  will  get MTA1
______  ____ ____
instead.

                               Page 28
Music Manual                                          Computing sound


The following generates  1 second of a  440 Hz sine wave  followed by
1/2  second of  a 660Hz  sine  wave and  outputs it  directly  to the
Digital-to-analog converter

COMMENT Fill array with sine wave;
ARRAY SINETABLE[511];
FOR I←0 STEP 1 UNTIL 511 DO SINETABLE[I]←SIN(2*PI/512);

INSTRUMENT SINE;
  COMMENT Generate simple sine wave.  P3 = Amplitude, P4 = frequency;
  OUTA←OUTA+OSCIL(P4,P3*MAG,SINETABLE);
  END;

COMMENT Now, generate the sound;
PLAY DAC:1.5;
  SIMP 0, 1, 1000, 440;
  SIMP 1, 1/2, 1000, 660;
  FINISH;


Arguments to instruments may be either numbers or array, and one must
be careful to use the right type, as the compiler does not  check for
you!  If you give an array  instead of a number, you will  merely get
meaningless results.  However, if you give a number when an  array is
expected, you will most likely get a message from the moniter such as

?
ERROR IN JOB 31
ILL MEM REF AT USER 7601
↑C
.
The first two parameters in an instrument call have a special meaning
to  MUSCMP.  Traditionally the  second  two parameters  are  are also
special meaning, but could be used for any purpose.  The meanings are
as follows:

P1     Begin time  Time  at  which  the  instrument  is  started,  in
__
                   seconds.
P2     Duration    Length of time instrument will be run, in seconds.
__
P3     Frequency   Typically  fundemental   frequence  or   pitch  of
__
                   instrument [optional].
P4     Amplitude   Typically maximum sample  to be generated  by this
__
                   instrument [optional].

Usually, arguments to instruments which are arrays usually  appear at
the end of an instrument call.  P3 and P4 are sometimes interchanged,
                                __     __
especially in FM instruments, so amplitude is P4 and frequency is P3.
                                              __                  __


                               Page 29
Music Manual                                          Computing sound


Because of the way instruments are compiled, it is not  possible call
the same instrument twice  during same time period.  This  is because
it has only one set of temperary variables.



8-3. FINISH statement
     ______ _________


A  FINISH  statement  terminates   a  PLAY  block.   It   causes  all
   ______
instruments to run  to completion and the  output file to  be closed.
It also asks you if you want to delete the temperary file which saved
the state of your computation on long runs.




































                               Page 30
Music Manual


                              Section 9
                              _______ _

                        Outputting the sound
                        __________ ___ _____






9-1. Short segments directly from MUSCMP
     _____ ________ ________ ____ ______

For simple tests of a  few seconds, it is probably easiest  to output
the sound directly from MUSCMP.  One does this by naming the digital-
to-analog converter in the PLAY statement, such as PLAY DAC:1.0; (for
                                                   ____ ________
details, see section on PLAY statement on page Page 28).



9-2. Longer segments using MUSCMP to write a sound file
     ______ ________ _____ ______ __ _____ _ _____ ____


For longer tests, one can write  a disk file which later send  to the
digital-to-analog converter without  change.  One does this  by using
something  like  PLAY DSK:TEST.SND/BYTESIZE=12/SOUND,  where  DSK: is
                 ____ ______________________________          ____
optional.  (Admittedly, this is  rather verbose and will  probably be
shorted soon.) When the computation is finished, one then runs one of
the disk playing programs:

          DAC     directly  from  DSK: or  [new]  UDP:  to  DAC:.  It
          Copies                  ____            ____      ____
          accepts  12 bit  or 18  bit files  and handles  1, 2,  or 4
          channels at 12.8 KHz  or 25.6 KHz.  Program attempts  to be
          self-documenting  and will  ask  you about  clock  rate and
          number of channels if it can't figure it out itself.



9-3. Production runs
     __________ ____

For production runs or long tests which need to be  interruptable, it
is best to write a series of files instead of one large one.  If just
a file name  is given to  MUSCMP with no  switches this is  what will
happen.  In addition,  this file is written  in 18 bit format  with a
special code at the end representing the maximum sample seen  so far.
These files are not suitable for playing directly, but do retain more
accuracy  than  the more  common  12  bit sound  files  and  could be
converted to some other byte  size at another time.  This  dates back
to when we only had a  12 bit DAC and wanted to  preserve significant
                              ___


                               Page 31
Music Manual                                     Outputting the sound


computations in a  form that could be  utilized by high  accuracy DAC
                                                                  ___
which we might obtain in the  future.  In order to send the  sound to
the DAC:, you must convert  the many files into one long  file.  This
    ____
is done  by a special  program called NMUSIO.   It takes one  or more
                                      ______
sequences of files and combines them into one large file which can be
written  on  either  the  DSK: or  an  old  format  UDP:.   Its basic
                          ____                      ____
operation  is as  follows.   It first  asks  for a  description  of a
sequence  of files.   This consists  of the  name of  the  first file
followed by a '-'  and then the name of  the last file.  It  looks to
see  how  they  are  different and  increments  the  first  file name
accordingly  to  access  the second  and  subsequent  files  until it
matches the  last filee.  It  then asks where  the output  should go.
This should be a single file (with an optional device specification).
NMUSIO then converts from 18 bit to 12 bit and does  optional scaling
(if for example, the samples in the 18 bit would not fit in a  12 bit
word).  When it finishes that sequence of files, it asks if  you want
to aadd another sequence by saying "More input?".  If you answer 'y',
it  will then  expect another  sequence specification  which  it will
convert and  asks you  again if  you have  another sequence.   If you
answer 'n', it will  close your files and  exit. You then run  one of
the programs described in the previous section to hear what it sounds
like.



























                               Page 32
Music Manual


                             Appendix A
                             ________ _

                               Syntax
                               ______




Note:  {<foo>} means there may be from 0 to ∞ occurances of <foo>.

<block>                 ::= BEGIN <declaration list>;<statement list>
<declaration list>      ::= <declaration>;<declaration list>|
                            <declaration>
<statement list>        ::= <statement>;<statement list>|END
<statement>             ::= <function call>|<unit generator call>|
                            <assignment statement>|<block>
                            <WHILE statement>|<UNTIL statement>|
                            <FOR statement>|<conditional statement>|
                            <PRINT statement>
<function call>         ::= <function>(<parameter list>)
<unit generator call>   ::= <unit generator>(<parameter list>)|
                     <unit generator>[<expression>](<parameter list>)
<parameter list>        ::= <parameter>,<parameter list>|<parameter>
<parameter>             ::= <expression>|<array>|<string constant>
<FOR statement>         ::= FOR <variable>←<expression> STEP
                            <expression> UNTIL <expression> DO
                            <statement>
<PRINT statement>       ::= PRINT <print list>
<print list>            ::= <expression>,<print list>|<expression>|
                            <string constant>,<print list>|
                            <string constant>
<WHILE statement>       ::= WHILE <conditional> DO <statement>
<UNTIL statement>       ::= DO <statement> UNTIL <conditional>
<assignment statement>  ::= <variable>←<expression>
<play block>            ::= PLAY; <play list> |
                            PLAY <filespec>; <play list>
<instrument call>       ::= <instrument><parameter list>
<extended commands>     ::= EXIT|P <integer>|PRINT <expression>;|
                            RESET|FREEZE|SPACE|DDT|
                            <declarator> LIST
<declarator>            ::= VARIABLE|ARRAY|FUNCTION|INSTRUMENT|
                            UNIT_GENERATOR
<declaration>           ::= <variable declaration>|
                            <array declaration>|
                            <function declaration>|
                            <instrument declaration>
<variable declaration>  ::= VARIABLE <var. dec. list>
<var. dec. list>        ::= <identifier>,<var. dec. list>|
                            /<identifier>,<var. dec. list>|

                               Page 33
Music Manual                                                   Syntax


                            <identifier>|/<identifier>
<array declaration>     ::= ARRAY <array decl. list>
<array decl. list>      ::= <array decl. group>,<array decl. list>|
                            <array decl. group>
<array decl. group>     ::= <variable>,<array decl. group>|
                            <variable>(<constant>)
<function declaration>  ::= FUNCTION <identifier>(<formal list>)
                                <function tail>|
                            EXTERNAL FUNCTION <identifier>
                                (<formal list>)
<formal list>           ::= <formal declaration>{,<formal list>}
<formal declaration>    ::= ARRAY <identifier> |
                            INTEGER <identifier>|
                            STRING <identifier> |
                            <identifier>
<function tail>         ::= ; <block> | = <expression>
<instrument declaration>::= INSTRUMENT <identifier>;
                            <declaration list>;<statement list>
<expression>            ::= <term>|<term><addop><expression>
<term>                  ::= <factor>|<factor><mulop><term>
<factor>                ::= <primary>
<primary>               ::= -<primary>|(<expression>)|<variable>|
                            <function call>|<unit generator call>|
                            <array name>(<expression>)|<constant>
                            <variable>←<expression>
<addop>                 ::= +|-
<mulop>                 ::= *|/
<variable>              ::= <letter><var tail>|<letter>
<var tail>              ::= <alphanumeric><var tail>|<alphanumeric>
<alphanumeric>          ::= <letter>|<number>
<letter>                ::= A|B|C|...Z|_|$|#
<digit>                 ::= 0|1|2|...9

















                               Page 34
Music Manual


                             Appendix B
                             ________ _

                           Reserved Words
                           ________ _____



ARRAY             EXIT              INTEGER           RPRINT
BEGIN             EXTERNAL          LENGTH            STEP
COMMENT           FINISH            LIST              STRING
COMPILE           FOR               PI                THEN
DONE              FUNCTION          PLAY              UNIT_GENERATOR
DO                I_ONLY            PRINT             UNTIL
ELSE              IF                R_PRINT           VARIABLE
END               INSTRUMENT        RETURN            WHILE



































                               Page 36
Music Manual


                             Appendix C
                             ________ _

                         Predefined Symbols
                         __________ _______



_SKIP_     Variable        Used  by  obscure  external   routines  to
                           record failures
ABS        Function        Returns absolute value of number
ARRBLT     Function        Copies N elements between two arrays
BIGBIT     Variable        LCS compatability mode
COSCIL     Unit generator  Oscillator which remembers pointer between
CZOSCIL    Unit generator  Interpolating version of COSCIL
DA_SECONDS Variable        Number of  seconds of  sound to  buffer in
                           core for DAC
DEBUGFLAG  Variable        Enables    various    compiler   debugging
                           features
EXPEN      Unit Generator  Oscillator which doesn't wrap around
INT        Function        Returns  integer  part  of  floating point
                           number
INTRP      Unit generator  Interpolator driven by oscillator
LINEN      Unit Generator  Three part oscillator
LSBUF      Variable        Current size of DAC buffer
MAXSMP     Variable        Maximum sample seen
NCHNS      Variable        Number of channels active
NO_MSG     Variable        If nonzero, disable compiler messages
NOSCA      Unit generator  Oscillator with starting point given
NOSCIL     Unit Generator  Oscillator    which    accepts    negative
                           increments
OSCIL      Unit generator  Simple oscillator
OUT        Unit Generator  Equivalent to OUTA←OUTA+X
OUT2       Unit Generator  Equivalent  to  FUNCTION  OUT2(X,CH1,CH2);
                                           ________  ________________
                           BEGIN
                           _____
OUTA       Variable        Output channel A
OUTB       Variable        Output channel B
OUTC       Variable        Output channel C
OUTD       Variable        Output channel D
OUTSPEC    String          Output specification
P_ARRAY    Array           P1,P2,P3,...
RAND       Function        Returns a pseduo-random number  between -1
                           and 1
RANDH      Unit generator  Oscillator controlled random  numbers with
                           hold
RANDI      Unit generator  Oscillator controlled random numbers with
RCDFLG     Variable        LCS compatability mode
REV1       Unit Generator  Comb Filter (Reverberator)
REV2       Unit Generator  All-Pass Reverberator


                               Page 37
Music Manual                                       Predefined Symbols


REVINIT    Unit generator  If nonzero, reverberator arrays are zeroed
                           when
SPEED      Variable        Speed at which to run DAC (see SETCLOCK)
SRATE      Variable        Sampling rate
TIMESC     Variable        Time  scale used  for  half-speed recoding
                           (obsolete)
VALUE      Unit generator  Returns its first argument
VFMULT     Unit Generator  Multiplies amplitude by array element
ZEXPEN     Unit Generator  Interpolating   oscillator   without  wrap
                           around
ZINTRP     Unit generator  Interpolator   driven   by   interpolating
                           oscillator
ZOSCA      Unit generator  Interpolating  oscillator   with  starting
                           point given
ZOSCIL     Unit generator  Interpolating oscillator  OUTA←OUTA+X*CH1;
                           OUTB←OUTB+X*CH2;      END;     initialized
                           instrument calls interpolation
































                               Page 38
Music Manual


                             Appendix D
                             ________ _

                           Error Messages.
                           _____ _________




A simple statement inside a 'COMPILE' section just wastes space!
_ ______ _________ ______ _ _________ _______ ____ ______ ______
It will never be executed.

ARRGH! INIT with WAITBIT gave error return!?!!
______ ____ ____ _______ ____ _____ __________
Horrible system error. Shouldn't happen

Array expected in function or U.G. call, but number found instead. Pr
_____ ________ __ ________ __ ____ _____ ___ ______ _____ ________ __
Either a  function or  Unit Generator  was called  with a  Pn symbol,
which should have  be an array, but  instead a floating  point number
was found.  This is usually caused by passing a number instead  of an
array  in an  instrument call,  or an  error in  the  instrument with
respect to the numbering of the Pn arguments.

Attempt to do numeric operation on a string!
_______ __ __ _______ _________ __ _ _______
String comparison not implemented.

Attempt to do numeric operation on a string!
_______ __ __ _______ _________ __ _ _______
You have given a string to a numeric operator, such as '+', '-', '*',
'/', '>', etc.

Attempt to reference unit generator output at R-Time
_______ __ _________ ____ _________ ______ __ ______
At I-time, the output of a unit generator is undefined.

Byte size not 12 or 18 bits for DAC
____ ____ ___ __ __ __ ____ ___ ___
Other byte sizes are not  handled by this device.  Will use  a 12-bit
bytesize anyway (caveat).

C O M P I L E R   E R R O R  ! ! ! Get TOVAR or save this core image 
_ _ _ _ _ _ _ _   _ _ _ _ _  _ _ _ ___ _____ __ ____ ____ ____ _____ 
Something  unexpected has  happened  which would  probably  should be
looked at as it is most likely a bug.

Can't INIT AD
_____ ____ __
Digital to Analog Converter is probably in use.

Can't INIT DAC
_____ ____ ___
Digital to Analog Converter is probably in use.

Can't INIT DSK!
_____ ____ ____
An unlikely situation.

Can't INIT TTY!
_____ ____ ____

                               Page 39
Music Manual                                          Error Messages.


An unlikely situation.

Can't INIT mag tape
_____ ____ ___ ____
Someone else is probably using it.

Can't OPEN output file
_____ ____ ______ ____
Usually this means the file is protected or already being written.

Can't delete .SAV file
_____ ______ ____ ____
Perhaps someone is referencing it.

Can't expand core!
_____ ______ _____
Could get enough core.  You lose.

Can't expand core
_____ ______ ____

Can't have an R-time statement controlled by an I-time conditional
_____ ____ __ ______ _________ __________ __ __ ______ ___________
The  DO  ...  UNTIL   statement  will  never  terminate   under  such
circumstances.

Can't re-INIT output device.
_____ _______ ______ _______
Someone else it probably using it.

Can't reduce core!
_____ ______ _____
Shouldn't happen.

Can't setup buffers for output
_____ _____ _______ ___ ______
This error is probably due to some change to I/O in system.

DAC error
___ _____
Error detected while outputing to the DAC.

DONE statement illegal here
____ _________ _______ ____

DRYROT IN MAG. TAPE ROUTINE
______ __ ____ ____ _______

Dangling ELSE or extraneous ';' in IF...THEN...ELSE statement
________ ____ __ __________ ___ __ ________________ _________
The statement following the 'THEN' in a IF...THEN...ELSE statement is
terminated by the ELSE and should not have a semicolon after it.

Declarations should be made at start of block
____________ ______ __ ____ __ _____ __ _____
You may continue from this error.

Dimension should be a number
_________ ______ __ _ ______
Dynamic arrays are not implimented.

ERROR IN READING THE BITMAP/DIRECTORY
_____ __ _______ ___ ________________


                               Page 40
Music Manual                                          Error Messages.


ERROR IN SETTING UP BUFFER RINGS
_____ __ _______ __ ______ _____

ERROR IN WRITING BITMAP!
_____ __ _______ _______

ERROR IN WRITING TAPE DIRECTORY!
_____ __ _______ ____ __________
The tape files were  written correctly, however, the  directory could
not be written out properly.  Use tape fixing program on this one.

EXIT statement illegal outside of block
____ _________ _______ _______ __ _____

EXPRESSION TOO COMPLEX, MAY BE A COMPILER BUG
__________ ___ ________ ___ __ _ ________ ___

Expected to find a '←' here
________ __ ____ _ ___ ____
The compiler assumed you had begun an assignment statement.

External functions only, please
________ _________ _____ ______
The compiler does not know about anything else being external.

FORWARD REF. TO UNIT GENERATOR
_______ ____ __ ____ _________
You have most likely referenced the output of a unit  generator which
have  not  been defined  yet.  [If there  are  no Un  symbols  in the
expression, it may be a compiler bug.]

ILLEGAL DEBUGFLAG SETTING
_______ _________ _______

ILLEGAL FILE NAME
_______ ____ ____

ILLEGAL FORMAL PARAMETER
_______ ______ _________

IMPROPER ARRAY PARAMETER
________ _____ _________

IMPROPER STRING PARAMETER
________ ______ _________

INIT failed for that device
____ ______ ___ ____ ______

INPUT ERROR
_____ _____

INTEGERS PRESENTLY ALLOWED ONLY FOR EXTERNAL FUNCTIONS, SORRY
________ _________ _______ ____ ___ ________ __________ _____

Illegal byte size, ignored
_______ ____ _____ _______

Illegal character in number
_______ _________ __ ______
Not a digit or decimal point.

Illegal character
_______ _________
A character was found in file which has no meaning to the compiler.

Illegal declaration
_______ ___________

                               Page 41
Music Manual                                          Error Messages.


You  may not  make a  declaration of  type UNIT_GENERATOR,  STRING or
INTEGER.

Illegal primary
_______ _______

Illegal primary
_______ _______
Should be a number, variable, array or function call.

It appears that your tape directory has been garbaged.
__ _______ ____ ____ ____ _________ ___ ____ _________
Read error or some sort of inconsistancy on directory.

MAG TAPE ERROR???!?
___ ____ __________

MAG. TAPE ERROR
____ ____ _____

Missing '(' after array
_______ ___ _____ _____
You are probably trying to use a array as a variable.  Arrays must be
subscripted.

Missing '(' in array declaration
_______ ___ __ _____ ___________

Missing '(' in function call
_______ ___ __ ________ ____

Missing ')' after array subscript
_______ ___ _____ _____ _________

Missing ')' in array declaration
_______ ___ __ _____ ___________

Missing ')' in expression
_______ ___ __ __________
Unbalanced parentheses or missing operator in expression.

Missing ')' in function definition
_______ ___ __ ________ __________

Missing ')' or too many parameters in function call
_______ ___ __ ___ ____ __________ __ ________ ____

Missing ';' or '=' in function definition
_______ ___ __ ___ __ ________ __________

Missing ';'
_______ ___

Missing ';'
_______ ___
Statements should be terminated with a semicolon

Missing '=' in BYTESIZE
_______ ___ __ ________

Missing 'BEGIN' in function definition
_______ _______ __ ________ __________

Missing 'DO' in FOR
_______ ____ __ ___

Missing 'END'
_______ _____

                               Page 42
Music Manual                                          Error Messages.


Missing 'STEP' in FOR
_______ ______ __ ___

Missing 'THEN'
_______ ______
'THEN' Missing in IF...THEN...ELSE Statement.

Missing 'UNTIL' in FOR
_______ _______ __ ___

Missing 'UNTIL'
_______ _______
UNTIL missing from DO ... UNTIL statement or extraneous ';`.

Missing ']' in unit generator call
_______ ___ __ ____ _________ ____

Missing '←' in FOR
_______ ___ __ ___

Missing DO in WHILE statement
_______ __ __ _____ _________

Missing END
_______ ___
FINISH statement giving inside a block.

Missing External function
_______ ________ ________
Either  an  external  function  was  not  loaded  or  its   name  was
misspelled.

Missing IDENTIFIER
_______ __________

Multiply defined symboi
________ _______ ______

Multiply dimensional array not implimented, sorry
________ ___________ _____ ___ ____________ _____

Multiply dimensioned arrays not implemented
________ ___________ ______ ___ ___________
You may also have confused an array name with a function name.

NEGATIVE INC. TO OSCIL
________ ____ __ _____
OSCIL is not defined to go accept a negative increment however if you
continue from  this error it  will treat this  increment as  a NOSCIL
does.

NOT ALLOWED IN 'PLAY' SECTION
___ _______ __ ______ _______

NUMERIC ARGUMENT REQUIRED HERE
_______ ________ ________ ____
A string was found where a numberic argument was expected.

Negative increment to LINEN
________ _________ __ _____
LINEN  is  undefined for  negative  increments.  The  results  may be
unpredicatable.

Negative increment to ZEXPEN
________ _________ __ ______


                               Page 43
Music Manual                                          Error Messages.


ZEXPEN is undefined for  negative increments however if  you contiune
it will treat it like a ZOSCIL.

Never heard of that switch
_____ _____ __ ____ ______

OUTn too big, clipped
____ ___ ____ _______
Sample  just computed  was  too big  to  represent in  the  byte size
currently being used for  output. This usually is indicative  of some
problem in an instrument.

Output error?
______ ______
Error detected while writing out sample buffer

PARITY ERROR ON MAG. TAPE
______ _____ __ ____ ____

R-Time condition for I-Time Statement in WHILE statement
______ _________ ___ ______ _________ __ _____ _________
No R-Time  code was  generated after an  R-Time conditional.    It is
most likely that this will result in an infinite loop!

R-Time conditional for I-time IF-THEN-ELSE statement
______ ___________ ___ ______ ____________ _________
No R-time code was  generated after an R-Time  conditional. Therefore
the IF-THEN statement acts as  if the condition were always  true for
the 'THEN' clause and always false for the 'ELSE' clause!

RETURN statement illegal outside of function definition
______ _________ _______ _______ __ ________ __________
Only functions may return a value.  Use EXIT to leave a block.

SETPR2 failed! Therefore, can't do output to mag tape.
______ _______ __________ _____ __ ______ __ ___ _____
The program peeks  at the monitor  to find out  what the mag  tape is
doing.  The UUO which permits this failed.

STRING REQUIRED HERE
______ ________ ____
Something other  than a  string found  as an  argument to  a function
which expected a string as (one of) its arguments.

SWAP failed
____ ______

Simple variable required here
______ ________ ________ ____
FOR loops expect a simple variable, i.e. not an array.

Storage full!
_______ _____

String too long or missing "
______ ___ ____ __ _______ _
Strings have a limited length.

Subscript out of bounds at compile time.
_________ ___ __ ______ __ _______ _____
You have a subscript  expression which evaluates to a  constant which
is either too large or too small.

                               Page 44
Music Manual                                          Error Messages.


Tape full and no checkpoint to restart from.
____ ____ ___ __ __________ __ _______ _____

This feature can not be used on DEC systems yet. Sorry.
____ _______ ___ ___ __ ____ __ ___ _______ ____ ______
There are  some things you  can do  at Stanford that  you can  not do
elsewhere.

This isn't FORTRASH. Use a '←' assignment next time
____ _____ _________ ___ _ ___ __________ ____ ____
However '=' will be accepted under protest.

Too few arguments in function call
___ ___ _________ __ ________ ____

Too many END statements
___ ____ ___ __________

Too many parameters in function call
___ ____ __________ __ ________ ____

Type mismatch for assignment
____ ________ ___ __________
You are trying to assign a  string to a numeric variable or  a number
to a string variable!

UDP in use or assignned to another job
___ __ ___ __ _________ __ _______ ___

UNDEFINED IDENTIFIER
_________ __________

UNDEFINED IDENTIFIER
_________ __________
An identifier was used before it was declared.

Undefined IDENTIFIER
_________ __________

Unexpected symbol beginning a statement
__________ ______ _________ _ _________
It will be ignored and attempt to continue compilation.

Unimplimented operation
_____________ _________
AND and OR are not implimented.

Unit Generator call illegal outside of instrument definition
____ _________ ____ _______ _______ __ __________ __________
Unit generators  are only to  be used inside  of instruments  as they
require special initialization at I-time.

Unit generator call illegal outside of instrument definition
____ _________ ____ _______ _______ __ __________ __________
Unit generators  are only to  be used inside  of instruments  as they
require special initialization at I-time.

Use of two relational operator is illegal here
___ __ ___ __________ ________ __ _______ ____
The compiler doesn't know  how to deal with expression  like '2>X>9'.
Write it as two conditions.

You are calling an instrument which is already running!
___ ___ _______ __ __________ _____ __ _______ ________


                               Page 45
Music Manual                                          Error Messages.


Since the code generated for instruments is non-reentrant, you should
not  call  it with  overlapping  time periods  as  this  will produce
unpredicable  results.  Instead  you  should make  a copy  of  with a
different name  (and different  variable names  if they  are declared
outside that instrument).

You can't subscript an array with a string!
___ _____ _________ __ _____ ____ _ _______
An array can only be subscripted by something that evaluates to  be a
number.

You have the wrong pack mounted on the UDP
___ ____ ___ _____ ____ _______ __ ___ ___
The password for the UDP scratch pack was not correct.





































                               Page 46
Music Manual


                             Appendix E
                             ________ _

                         Changes since MUS10
                         _______ _____ _____




Most of the problems which  caused the message ILL MEM REF  have been
eliminated.   If  come  across  any problems  or  have  any  needs or
suggestions,  Please bring  them  to my  attention by  saying  to the
Monitor:

.MAIL TVR


The MAIL program will explain itself.

The  sample  output routines  have  been rewritten  to  eliminate the
BIGBIT  kludge.  The  intermediate files  whose extensions  have been
MUSAA.DMD are  now in the  form: <file name>.<integer>,  for example:
TEST.0,  TEST.1, TEST.2,...  Now more  than one  set  of intermediate
files may be  on the disk at  one time an any  set may be  deleted by
saying DEL <file name>.*, for example DEL TEST.*. The format has also
been changed, since it is  no longer done with FORTRAN.   Therefore a
new  conversion  program has  also  been written  to  replace CONNEW,
called NMUSIO.   A programmed  called DAC  is used  to play  from the
disk.  For details, see Page 27.

The error printout routines now contain an option to continue,  or to
edit, to retry, or to debug with DDT.

Core is obtained  automatically, whenever possible.   It occasionally
loses under certain circumstances.

Play now prints the run time used in computing the samples.

When the Compiler asks for  an input file, it is no  longer necessary
to precede a file name with DSK:.  If just a return is typed, TTY: is
assumed.

The Compiler will accept files editted by TVED or E.

When inputting  from the TTY,  SYNTH and SEG  will display  the array
being filled.

MUSCMP  should generate  slightly better  code and  evaluate constant
expressions during compilation.


                               Page 47
Music Manual                                      Changes since MUS10


Array elements may  be individually referenced.  This  allows complex
waveforms  to   be  described   by  arbitrarily   complex  mathematic
expression, instead  of the previous  restrictions to  combination of
sine waves or approximation by line segments.

There is a  new set of statements  and block structure  added.  These
statements include  IF,  WHILE,  UNTIL and  FOR statements.   A print
statement  has  been  added  which  allows  literal  strings  so that
messages may be printed as well as numbers, which are now  printed in
floating point notation.  The literal strings  may also be  passed to
functions. In order to  use certain routines in the  FORTRAN Library,
the data type INTEGER has been added but is currently limited  to the
external functions  until type  conversion code can  be added  to the
compiler.

Functions may now be blocks as well as expressions.

To make debugging the  compiler easier, a special debugging  mode has
been added.






























                               Page 48
                            Music Manual


                              I N D E X

                  (References are to Page numbers)


ABS                            26   identifier                      3
Absolute value                 26   increment                      19
ALOG                           26   index                           9
argument                        5   Instrument Call                28
Array Declaration               4   Instrument call parameters     29
Array Subscripting           4, 8   Instrument Declaration          6
Assignment statement        5, 11   INT                            26
                                    Integer                         4
BEGIN                          13   INTRP                          20
BIGBIT                         47
Block                      13, 14   KL10 Incompatability           26

called by reference             5   LENGTH                         25
Controlled Calling Rates       17   LINEN                          18
COS                            26   LIST                           16
COSCIL                         19   local variable                 13
Cosine                         26   local variables                 5
CZOSCIL                        21   Logarithm                      26

DAC                15, 27, 28, 31   MAG                            19
DDT                            15   Magnetic tape                  27
Declaration            3, 4, 5, 6
DMD                            47   NOSCA                          20
DONE                           14   NOSCIL                         19

END                            13   OSCIL                          19
EXCISE                         15
EXIT                       14, 15   P_Array                         3
EXP                            26   P-variables                     4
EXPEN                          20   parameters                   5, 8
Exponent                       27   Play                           15
Expressions                     7   PNUM                           24
Extended Commands          15, 16   PRINT                  12, 15, 24
External                        6   Pseudo-random numbers          25

FINISH statement           28, 30   RAID                           15
FOR                        12, 14   RAND                           25
formal parameter                5   RANDH                          22
FORTRAN                         6   RANDI                          22
FORTRAN I/O                    24   Random numbers                 25
Function Call               8, 10   RDNUM                          25
Function Declaration            5   Real                            4
                                    Relational operators            7

                               Page 49
                            Music Manual







Reserved Words                 36
RETURN                      6, 14

SEE                            24
SEG                            23
SETCLOCK                       24
SIN                            26
Sine                           26
SPACE                          15
Special variables               3
SQRT                           26
Square root                    26
Statement      10, 11, 12, 13, 14
String                      4, 12
subroutine                  8, 10
subscript                       9
Symbol Table                   16
Syntax                     33, 34
SYNTH                          23

U-variables                  3, 8
U-varibles                     11
UDP                        27, 31
Unit Generator17, 18, 19, 20, 21,
                               22
Unit Generator Call         8, 10
UNTIL                      11, 14

VALUE                          18
Variable Declaration            3
VFMULT                         17

WHILE                      11, 14

ZEXPEN                         21
ZINTRP                         21
ZOSCA                          21
ZOSCIL                         21






                               Page 50